package com.GlobalPaint.app.ui.HTML;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.GlobalPaint.app.R;
import com.GlobalPaint.app.bean.PaletteDetailsBean;
import com.flyco.tablayout.listener.CustomTabEntity;

import java.util.ArrayList;

public class tujiActivity extends AppCompatActivity {
    private PaletteDetailsBean.DataBean Bean;
    private ViewPager viewPager;
    private ArrayList<Fragment> fragments;
    private ArrayList<CustomTabEntity> tabEntities;
    private ImageView iv_goback;
    private TextView tv_common_center;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tuji);
        Bean= (PaletteDetailsBean.DataBean) getIntent().getSerializableExtra("serinfo");
        initView();
    }

    private void initView() {
        iv_goback = (ImageView) findViewById(R.id.iv_goback);
        iv_goback.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        tv_common_center = (TextView) findViewById(R.id.tv_common_center);
        tv_common_center.setText("详情");
        viewPager = (ViewPager) findViewById(R.id.atm_viewpager);
        fragments = new ArrayList<>();
      /*  for (int i = 0; i < Bean.getFImage().size(); i++) {
            fragments.add(new tijiFragment( Bean.getFImage().get(i)));
        }*/
        tabEntities = new ArrayList<>();
        viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return fragments.get(position);
            }

            @Override
            public int getCount() {
                return Bean.getFImage().size();//滑动的次数
            }

        });


        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
//				CommUtility.ShowMsgShort(getActivity(),"onPageScrolled");
            }

            @Override
            public void onPageSelected(int position) {

            }


            @Override
            public void onPageScrollStateChanged(int state) {
//				CommUtility.ShowMsgShort(getActivity(),"onPageScrollStateChanged");
            }
        });
        viewPager.setOffscreenPageLimit(2);
        viewPager.setCurrentItem(0);
    }
}
